class Customer {
  final String id;
  final String name;
  final String phone;
  final String address;
  final double totalPurchases;
  final int purchaseCount;
  final DateTime lastPurchase;
  final String notes;

  Customer({
    required this.id,
    required this.name,
    required this.phone,
    required this.address,
    required this.totalPurchases,
    required this.purchaseCount,
    required this.lastPurchase,
    required this.notes,
  });

  factory Customer.fromJson(Map<String, dynamic> json) {
    return Customer(
      id: json['id'] as String,
      name: json['name'] as String,
      phone: json['phone'] as String,
      address: json['address'] as String,
      totalPurchases: (json['totalPurchases'] as num).toDouble(),
      purchaseCount: json['purchaseCount'] as int,
      lastPurchase: DateTime.parse(json['lastPurchase'] as String),
      notes: json['notes'] as String,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'name': name,
      'phone': phone,
      'address': address,
      'totalPurchases': totalPurchases,
      'purchaseCount': purchaseCount,
      'lastPurchase': lastPurchase.toIso8601String(),
      'notes': notes,
    };
  }
} 